﻿using System.Collections.Generic;
using ReporterEngine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace ReportEngine_TestProject
{
    
    
    /// <summary>
    ///This is a test class for LexPathTest and is intended
    ///to contain all LexPathTest Unit Tests
    ///</summary>
    [TestClass()]
    public class LexPathTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        ///// <summary>
        /////A test for Scan
        /////</summary>
        //[TestMethod()]
        //public void ScanTest()
        //{
        //    //string path = ">> [ test2 *= 7 and name == \"nazov\"] >> method1() >> node1 << subject"; // TODO: Initialize to an appropriate value
        //    string path = ">> orderby(' name ', titem1)"; // TODO: Initialize to an appropriate value
        //    //string path = ">> [ name ^= \"domain\"]"; // TODO: Initialize to an appropriate value
        //    //string path = ">> [@alias1 >> id == id]"; // TODO: Initialize to an appropriate value
        //    //string path = ">> ' prop1 ' >> iit"; // TODO: Initialize to an appropriate value
        //    LexPath expected = null; // TODO: Initialize to an appropriate value
        //    LexPath actual;

        //    actual = LexPath.Scan(path);

        //    Assert.AreEqual(expected, actual);
        //    Assert.Inconclusive("Verify the correctness of this test method.");
        //}

        /// <summary>
        ///A test for error Scan
        ///</summary>
        [TestMethod()]
        public void ScanErrorTest()
        {
            var list = new List<TestString>();

            list.Add(new TestString { Text = ">> aa()( >> bb >> cc", Expected = 7 });
            list.Add(new TestString { Text = ">> aa()( >> bb >> cc", Expected = 7 });
            list.Add(new TestString { Text = ">> aa() dd >> bb >> cc", Expected = 8 });
            list.Add(new TestString { Text = ">> aa > bb >> cc", Expected = 6 });
            list.Add(new TestString { Text = ">> aa < bb >> cc", Expected = 6 });

            foreach (var cutItem in list)
            {
                var actual = LexPath.Scan(cutItem.Text);

                Assert.AreEqual(cutItem.Expected, actual.ErrorPosition);
            }
        }

        public class TestString
        {
            public string Text;
            public int Expected;

            public string ExpectedValue;

            public bool IsValueType;
        }

    }
}
